<template>
  <div class="dialog-container">
    <el-dialog
      :title="'运维单详情——'+maintenanceData.equipmentTypeName"
      :visible="dialogVisible"
      @opened="initData"
      @close="closeDialog"
    >
      <div>
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane v-for="(item, index) in maintenanceData.list" :key="index" :label="item.formTempIdName" :name="'maintenaIndex'+index" />
        </el-tabs>
        <div class="custom-table-panel">
          <component :is="flag" ref="form2" :obj="dataForm" :maintena-index="maintenaIndex" :detail="true" />
        </div>
        <div class="custom-table-panel">
          <el-form :disabled="true">
            <el-form-item label="运维结果评价">
              <el-rate
                v-model="evaluate.overallEvaluation"
                show-score
                text-color="#ff9900"
                score-template="{value}"
              />
            </el-form-item>
            <el-form-item label="处置人员评价">
              <el-rate
                v-model="evaluate.disposalPersonnelEvaluation"
                show-score
                text-color="#ff9900"
                score-template="{value}"
              />
            </el-form-item>
            <el-form-item label="内容说明">
              <el-input v-model="evaluate.contentDescription" type="textarea" />
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div v-show="!show">无</div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" class="sure-btn" size="mini" @click="closeDialog">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
// import Jy from './form/jy'
// import Wh from './form/wh'
// import Pjgh from './form/pjgh'
// import Xj from './form/xj'
// import Fyhs from './form/fyhs'
// import Bd from './form/bd'
// import Sjgh from './form/sjgh'
// import Yqxj from './form/yqxj'
// import Yqwh from './form/yqwh'
// import Yqgh from './form/yqgh'
// import Yqjz from './form/yqjz'
// import Yqbd from './form/yqbd'
import FS_BS_BC_JLB from './jsonForm/FS_BS_BC_JLB'
import FS_BZYPGH_JLB from './jsonForm/FS_BZYPGH_JLB'
import FS_CSSZ_JLB from './jsonForm/FS_CSSZ_JLB'
import FS_FYSJ_JLB from './jsonForm/FS_FYSJ_JLB'
import FS_JX_JLB from './jsonForm/FS_JX_JLB'
import FS_JZJG_JLB from './jsonForm/FS_JZJG_JLB'
import FS_SYJG_JLB from './jsonForm/FS_SYJG_JLB'
import FS_XJWH_JLB from './jsonForm/FS_XJWH_JLB'
import FS_YHPGH_JLB from './jsonForm/FS_YHPGH_JLB'
import FS_ZDJCYJY_JL from './jsonForm/FS_ZDJCYJY_JL'
import YQ_BS_BC_JL from './jsonForm/YQ_BS_BC_JL'
import YQ_JYCS_JL from './jsonForm/YQ_JYCS_JL'
import YQ_PYYJZ_JLB from './jsonForm/YQ_PYYJZ_JLB'
import YQ_QTGH_JL from './jsonForm/YQ_QTGH_JL'
import YQ_RCXJ_JLB from './jsonForm/YQ_RCXJ_JLB'
import YQ_WX_JLB from './jsonForm/YQ_WX_JLB'
import YQ_YHPGH_JLB from './jsonForm/YQ_YHPGH_JLB'
import { selectTMaintenanceDetailsDto } from '@/api/maintenanceManage'
export default {
  name: '',
  components: {
    // Wh, Pjgh, Xj, Yqxj, Yqwh, Yqgh, Yqjz, Yqbd, Jy, Fyhs, Bd, Sjgh,
    FS_BS_BC_JLB,
    FS_BZYPGH_JLB,
    FS_CSSZ_JLB,
    FS_FYSJ_JLB,
    FS_JX_JLB,
    FS_JZJG_JLB,
    FS_SYJG_JLB,
    FS_XJWH_JLB,
    FS_YHPGH_JLB,
    FS_ZDJCYJY_JL,
    YQ_BS_BC_JL,
    YQ_JYCS_JL,
    YQ_PYYJZ_JLB,
    YQ_QTGH_JL,
    YQ_RCXJ_JLB,
    YQ_WX_JLB,
    YQ_YHPGH_JLB
  },
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    obj: {
      type: Object,
      default: null
    },
    formType: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      flag: '',
      activeName: 'maintenaIndex0',
      dataForm: {},
      maintenaIndex: 0,
      maintenanceData: {
        equipmentTypeName: '设备类型'
      },
      evaluate: {
        overallEvaluation: 0,
        disposalPersonnelEvaluation: 0,
        contentDescription: ''
      },
      show: true
    }
  },
  created() {},
  mounted() {},
  methods: {
    initData() {
      this.evaluate = this.obj
      selectTMaintenanceDetailsDto({ 'maintenanceId': this.obj.id }).then(res => {
        if (res.data.list && res.data.list.list.length !== 0) {
          this.show = true
        } else {
          this.show = false
          return
        }
        this.maintenanceData = res.data.list
        console.log(this.maintenanceData)
        this.flag = this.maintenanceData.list[0].modelUrl
        this.dataForm = this.maintenanceData
        this.maintenaIndex = 0
        if (this.formType) {
          for (var i = 0; i < this.maintenanceData.list.length; i++) {
            if (this.maintenanceData.list[i].formTempIdName === this.formType) {
              this.maintenaIndex = i
              this.activeName = 'maintenaIndex' + i
              this.flag = this.maintenanceData.list[i].modelUrl
              break
            }
          }
        }
        this.$nextTick(() => {
          if (this.$refs.form2) {
            this.$refs.form2.init()
          }
        })
      })
    },
    closeDialog() {
      this.$emit('closeDialog')
      this.clearData()
    },
    handleClick(val) {
      var index = parseInt(val.index)
      this.maintenaIndex = index
      this.flag = this.maintenanceData.list[index].modelUrl
      debugger
      if (this.$refs.form2) {
        this.$refs.form2.init()
      }
    },
    clearData() {
      this.flag = ''
      this.dataForm = {}
      this.maintenaIndex = 0
      this.maintenanceData = {
        equipmentTypeName: '设备类型'
      }
      this.evaluate = {
        overallEvaluation: 0,
        disposalPersonnelEvaluation: 0,
        contentDescription: ''
      }
      this.show = true
      this.activeName = 'maintenaIndex0'
    }
  }
}
</script>

<style lang='scss' scoped>
</style>
